package cn.wygandwdn.learn.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: WYG
 * @time: 2021/5/6 19:41
 */
@Aspect
@Component
public class TechnologyAop {
    @DeclareParents(
            value = "cn.wygandwdn.learn.aop.ITask",
            defaultImpl = Log.class
    )
    public ILog log;

    @Pointcut("execution(* cn.wygandwdn.learn.service.*Service.*(String))&& args(key)")
    public void technologyCut(String key) {}

    @Before("technologyCut(key)")
    public void BeforeTechnology(JoinPoint joinPoint, String key) {
        System.out.println("执行的方法是:" + joinPoint.getSignature());
        System.out.println("将系统操作日志插入数据库,那么这里调用的就是数据库的相关操作");
    }

    /*@AfterThrowing(pointcut = "execution(* cn.wygandwdn.learn.service.*Service.*(String))", throwing = "e")
    public void afterThrow(Exception e) {
        System.out.println("对异常进行处理");
    }
    @AfterReturning(pointcut = "execution(* cn.wygandwdn.learn.service.*Service.*(String))", returning = "r")
    public void afterReturn(String retValue) {
        System.out.println("进行相应操作");
    }
    @After("technologyCut(key)")
    public void after(String key) {
        System.out.println("进行相应操作");
    }
    @Around("technologyCut(key)")
    public void around(ProceedingJoinPoint joinPoint, String key) throws Throwable {
        System.out.println("进行相应操作");
        // 调用该方法继续执行调用链
        joinPoint.proceed();
    }*/
}
